package com.wman.lib.api;

import android.content.Context;

import com.wman.sheep.okgo.OkGo;
import com.wman.lib.utils.callback.BitmapCallback;

import java.util.HashMap;
import java.util.LinkedHashMap;

/**
 * 网络请求接口的实现
 */
public class ApiImpl implements Api {
    private Context context;
    private LinkedHashMap<String, Object> mParams;

    public ApiImpl(Context context) {
        this.context = context;
    }

    private HashMap getToken() {
        if (mParams == null) {
            synchronized (ApiImpl.class) {
                if (mParams == null) {
                    mParams = new LinkedHashMap();
                }
            }
        } else {
            synchronized (ApiImpl.class) {
                mParams.clear();
            }
        }

        return mParams;
    }


    @Override
    public void downloadImage(String url, BitmapCallback callback) {
        OkGo.get(url)
                .tag(context)
                .execute(callback);
    }
}

